package com.example.service.webhook.business.carrier.repository;

import com.example.service.webhook.business.carrier.entity.MonthInfoEntity;
import com.example.service.webhook.business.carrier.entity.MonthItemEntity;
import com.example.service.webhook.repository.base.BaseDAO;
import com.example.service.webhook.util.DateUtil;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @author liyang
 * @email liyang@51dojo.com
 * @create 2017-10-31 下午9:27
 * @description 话记录月份采集结果crud
 **/
@Repository
public class MonthInfoItemRepository extends BaseDAO<MonthItemEntity> {
    @Resource(name = "templateCarrier")
    private JdbcTemplate jdbcTemplate;

    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    public void saveMonthItemEntity(MonthItemEntity entity) throws Exception {
        entity.setCreateTime(DateUtil.getCurrentDate());
        entity.setLastModifyTime(DateUtil.getCurrentDate());
        this.add(entity);
    }

    public void deleteMonthItemEntity(String userId,String mappingId){
        String sql = "delete from t_monthitem where userId=? and mappingId=?";
        this.delete(sql, new Object[]{userId,mappingId});
    }
}